﻿<UserControl x:Class="ViewRelations"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
       
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <DataGrid AutoGenerateColumns="False" Name="RelationsDataGrid" ColumnWidth="*" RowHeight="30" IsSynchronizedWithCurrentItem="true" ItemsSource="{Binding}"  >
            <DataGrid.Columns >
                <DataGridTextColumn Header="Nom de la relation" Binding="{Binding Path=RelationName}"/>
                <DataGridComboBoxColumn Header="Table Parent" SelectedItemBinding="{Binding Path=ParentTable}" >
                </DataGridComboBoxColumn>
                <DataGridComboBoxColumn  Header="Table Enfant" SelectedItemBinding="{Binding Path=ChildTable}"  >
                </DataGridComboBoxColumn>
            </DataGrid.Columns>
            <DataGrid.CellStyle>
                <Style TargetType="DataGridCell">
                    <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />
                </Style>
            </DataGrid.CellStyle>
        </DataGrid>   
        
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>               
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <DockPanel Grid.ColumnSpan="3" Visibility="Collapsed"  >
                <Button Content="Ajouter" Margin="5" Padding="2" />
                <TextBox VerticalAlignment="Center" Margin="5" Text="{Binding /RelationName}"  />
            </DockPanel>

            <DataGrid AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="true" ColumnWidth="*" RowHeight="30" Name="RelationDetailsDataGrid" Grid.ColumnSpan="3" Grid.Row="1" ItemsSource="{Binding /Columns}" >
                <DataGrid.Columns >
                    <DataGridComboBoxColumn Header="Colonne Parent" SelectedItemBinding="{Binding Path=ParentDataColumn}" />
                    <DataGridComboBoxColumn  Header="Colonne Enfant" SelectedItemBinding="{Binding Path=ChildDataColumn}" />
                </DataGrid.Columns>
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="IsEnabled" Value="{Binding IsEnabled}" />
                    </Style>
                </DataGrid.CellStyle>
            </DataGrid>
        </Grid>
    </Grid>
</UserControl>
